package org.springframework.util;

import java.beans.Introspector;
import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.Proxy;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

public abstract class ClassUtils
{
  public static final String ARRAY_SUFFIX = "[]";
  public static final String CGLIB_CLASS_SEPARATOR = "$$";
  public static final String CLASS_FILE_SUFFIX = ".class";
  private static final char INNER_CLASS_SEPARATOR = '$';
  private static final String INTERNAL_ARRAY_PREFIX = "[";
  private static final String NON_PRIMITIVE_ARRAY_PREFIX = "[L";
  private static final char PACKAGE_SEPARATOR = '.';
  private static final Map<String, Class<?>> commonClassCache;
  private static final Map<String, Class<?>> primitiveTypeNameMap;
  private static final Map<Class<?>, Class<?>> primitiveTypeToWrapperMap;
  private static final Map<Class<?>, Class<?>> primitiveWrapperTypeMap = new HashMap(8);

  static
  {
    primitiveTypeToWrapperMap = new HashMap(8);
    primitiveTypeNameMap = new HashMap(32);
    commonClassCache = new HashMap(32);
    primitiveWrapperTypeMap.put(Boolean.class, Boolean.TYPE);
    primitiveWrapperTypeMap.put(Byte.class, Byte.TYPE);
    primitiveWrapperTypeMap.put(Character.class, Character.TYPE);
    primitiveWrapperTypeMap.put(Double.class, Double.TYPE);
    primitiveWrapperTypeMap.put(Float.class, Float.TYPE);
    primitiveWrapperTypeMap.put(Integer.class, Integer.TYPE);
    primitiveWrapperTypeMap.put(Long.class, Long.TYPE);
    primitiveWrapperTypeMap.put(Short.class, Short.TYPE);
    Iterator localIterator1 = primitiveWrapperTypeMap.entrySet().iterator();
    Iterator localIterator2;
    if (!localIterator1.hasNext())
    {
      HashSet localHashSet = new HashSet(32);
      localHashSet.addAll(primitiveWrapperTypeMap.values());
      localHashSet.addAll(Arrays.asList(new Class[] { [Z.class, [B.class, [C.class, [D.class, [F.class, [I.class, [J.class, [S.class }));
      localHashSet.add(Void.TYPE);
      localIterator2 = localHashSet.iterator();
    }
    while (true)
    {
      if (!localIterator2.hasNext())
      {
        registerCommonClasses(new Class[] { [Ljava.lang.Boolean.class, [Ljava.lang.Byte.class, [Ljava.lang.Character.class, [Ljava.lang.Double.class, [Ljava.lang.Float.class, [Ljava.lang.Integer.class, [Ljava.lang.Long.class, [Ljava.lang.Short.class });
        registerCommonClasses(new Class[] { Number.class, [Ljava.lang.Number.class, String.class, [Ljava.lang.String.class, Object.class, [Ljava.lang.Object.class, Class.class, [Ljava.lang.Class.class });
        registerCommonClasses(new Class[] { Throwable.class, Exception.class, RuntimeException.class, Error.class, StackTraceElement.class, [Ljava.lang.StackTraceElement.class });
        return;
        Map.Entry localEntry = (Map.Entry)localIterator1.next();
        primitiveTypeToWrapperMap.put((Class)localEntry.getValue(), (Class)localEntry.getKey());
        Class[] arrayOfClass = new Class[1];
        arrayOfClass[0] = ((Class)localEntry.getKey());
        registerCommonClasses(arrayOfClass);
        break;
      }
      Class localClass = (Class)localIterator2.next();
      primitiveTypeNameMap.put(localClass.getName(), localClass);
    }
  }

  public static String addResourcePathToPackagePath(Class<?> paramClass, String paramString)
  {
    Assert.notNull(paramString, "Resource name must not be null");
    if (!paramString.startsWith("/"))
      return classPackageAsResourcePath(paramClass) + "/" + paramString;
    return classPackageAsResourcePath(paramClass) + paramString;
  }

  public static String classNamesToString(Collection<Class> paramCollection)
  {
    if (CollectionUtils.isEmpty(paramCollection))
      return "[]";
    StringBuilder localStringBuilder = new StringBuilder("[");
    Iterator localIterator = paramCollection.iterator();
    while (true)
    {
      if (!localIterator.hasNext())
      {
        localStringBuilder.append("]");
        return localStringBuilder.toString();
      }
      localStringBuilder.append(((Class)localIterator.next()).getName());
      if (localIterator.hasNext())
        localStringBuilder.append(", ");
    }
  }

  public static String classNamesToString(Class[] paramArrayOfClass)
  {
    return classNamesToString(Arrays.asList(paramArrayOfClass));
  }

  public static String classPackageAsResourcePath(Class<?> paramClass)
  {
    if (paramClass == null)
      return "";
    String str = paramClass.getName();
    int i = str.lastIndexOf('.');
    if (i == -1)
      return "";
    return str.substring(0, i).replace('.', '/');
  }

  public static String convertClassNameToResourcePath(String paramString)
  {
    Assert.notNull(paramString, "Class name must not be null");
    return paramString.replace('.', '/');
  }

  public static String convertResourcePathToClassName(String paramString)
  {
    Assert.notNull(paramString, "Resource path must not be null");
    return paramString.replace('/', '.');
  }

  public static Class<?> createCompositeInterface(Class<?>[] paramArrayOfClass, ClassLoader paramClassLoader)
  {
    Assert.notEmpty(paramArrayOfClass, "Interfaces must not be empty");
    Assert.notNull(paramClassLoader, "ClassLoader must not be null");
    return Proxy.getProxyClass(paramClassLoader, paramArrayOfClass);
  }

  @Deprecated
  public static Class<?> forName(String paramString)
    throws ClassNotFoundException, LinkageError
  {
    return forName(paramString, getDefaultClassLoader());
  }

  public static Class<?> forName(String paramString, ClassLoader paramClassLoader)
    throws ClassNotFoundException, LinkageError
  {
    Assert.notNull(paramString, "Name must not be null");
    Class localClass1 = resolvePrimitiveClassName(paramString);
    if (localClass1 == null)
      localClass1 = (Class)commonClassCache.get(paramString);
    if (localClass1 != null)
      return localClass1;
    if (paramString.endsWith("[]"))
      return Array.newInstance(forName(paramString.substring(0, paramString.length() - "[]".length()), paramClassLoader), 0).getClass();
    if ((paramString.startsWith("[L")) && (paramString.endsWith(";")))
      return Array.newInstance(forName(paramString.substring("[L".length(), -1 + paramString.length()), paramClassLoader), 0).getClass();
    if (paramString.startsWith("["))
      return Array.newInstance(forName(paramString.substring("[".length()), paramClassLoader), 0).getClass();
    ClassLoader localClassLoader = paramClassLoader;
    if (localClassLoader == null)
      localClassLoader = getDefaultClassLoader();
    try
    {
      Class localClass3 = localClassLoader.loadClass(paramString);
      return localClass3;
    }
    catch (ClassNotFoundException localClassNotFoundException1)
    {
      int i = paramString.lastIndexOf('.');
      if (i != -1)
      {
        String str = paramString.substring(0, i) + '$' + paramString.substring(i + 1);
        try
        {
          Class localClass2 = localClassLoader.loadClass(str);
          return localClass2;
        }
        catch (ClassNotFoundException localClassNotFoundException2)
        {
        }
      }
      throw localClassNotFoundException1;
    }
  }

  public static Class[] getAllInterfaces(Object paramObject)
  {
    Assert.notNull(paramObject, "Instance must not be null");
    return getAllInterfacesForClass(paramObject.getClass());
  }

  public static Set<Class> getAllInterfacesAsSet(Object paramObject)
  {
    Assert.notNull(paramObject, "Instance must not be null");
    return getAllInterfacesForClassAsSet(paramObject.getClass());
  }

  public static Class<?>[] getAllInterfacesForClass(Class<?> paramClass)
  {
    return getAllInterfacesForClass(paramClass, null);
  }

  public static Class<?>[] getAllInterfacesForClass(Class<?> paramClass, ClassLoader paramClassLoader)
  {
    Set localSet = getAllInterfacesForClassAsSet(paramClass, paramClassLoader);
    return (Class[])localSet.toArray(new Class[localSet.size()]);
  }

  public static Set<Class> getAllInterfacesForClassAsSet(Class paramClass)
  {
    return getAllInterfacesForClassAsSet(paramClass, null);
  }

  public static Set<Class> getAllInterfacesForClassAsSet(Class paramClass, ClassLoader paramClassLoader)
  {
    Assert.notNull(paramClass, "Class must not be null");
    if ((paramClass.isInterface()) && (isVisible(paramClass, paramClassLoader)))
    {
      localObject = Collections.singleton(paramClass);
      return localObject;
    }
    Object localObject = new LinkedHashSet();
    label37: Class[] arrayOfClass;
    int i;
    if (paramClass != null)
    {
      arrayOfClass = paramClass.getInterfaces();
      i = arrayOfClass.length;
    }
    for (int j = 0; ; j++)
    {
      if (j >= i)
      {
        paramClass = paramClass.getSuperclass();
        break label37;
        break;
      }
      ((Set)localObject).addAll(getAllInterfacesForClassAsSet(arrayOfClass[j], paramClassLoader));
    }
  }

  public static String getClassFileName(Class<?> paramClass)
  {
    Assert.notNull(paramClass, "Class must not be null");
    String str = paramClass.getName();
    return str.substring(1 + str.lastIndexOf('.')) + ".class";
  }

  public static <T> Constructor<T> getConstructorIfAvailable(Class<T> paramClass, Class<?>[] paramArrayOfClass)
  {
    Assert.notNull(paramClass, "Class must not be null");
    try
    {
      Constructor localConstructor = paramClass.getConstructor(paramArrayOfClass);
      return localConstructor;
    }
    catch (NoSuchMethodException localNoSuchMethodException)
    {
    }
    return null;
  }

  public static ClassLoader getDefaultClassLoader()
  {
    try
    {
      ClassLoader localClassLoader2 = Thread.currentThread().getContextClassLoader();
      localClassLoader1 = localClassLoader2;
      if (localClassLoader1 == null)
        localClassLoader1 = ClassUtils.class.getClassLoader();
      return localClassLoader1;
    }
    catch (Throwable localThrowable)
    {
      while (true)
        ClassLoader localClassLoader1 = null;
    }
  }

  public static String getDescriptiveType(Object paramObject)
  {
    if (paramObject == null)
      return null;
    Class localClass = paramObject.getClass();
    if (Proxy.isProxyClass(localClass))
    {
      StringBuilder localStringBuilder = new StringBuilder(localClass.getName());
      localStringBuilder.append(" implementing ");
      Class[] arrayOfClass = localClass.getInterfaces();
      for (int i = 0; ; i++)
      {
        if (i >= arrayOfClass.length)
          return localStringBuilder.toString();
        localStringBuilder.append(arrayOfClass[i].getName());
        if (i < -1 + arrayOfClass.length)
          localStringBuilder.append(',');
      }
    }
    if (localClass.isArray())
      return getQualifiedNameForArray(localClass);
    return localClass.getName();
  }

  public static int getMethodCountForName(Class<?> paramClass, String paramString)
  {
    int i = 0;
    Assert.notNull(paramClass, "Class must not be null");
    Assert.notNull(paramString, "Method name must not be null");
    int j = 0;
    Method[] arrayOfMethod = paramClass.getDeclaredMethods();
    int k = arrayOfMethod.length;
    int m = 0;
    Class[] arrayOfClass;
    int n;
    if (m >= k)
    {
      arrayOfClass = paramClass.getInterfaces();
      n = arrayOfClass.length;
    }
    while (true)
    {
      if (i >= n)
      {
        if (paramClass.getSuperclass() != null)
          j += getMethodCountForName(paramClass.getSuperclass(), paramString);
        return j;
        if (paramString.equals(arrayOfMethod[m].getName()))
          j++;
        m++;
        break;
      }
      j += getMethodCountForName(arrayOfClass[i], paramString);
      i++;
    }
  }

  public static Method getMethodIfAvailable(Class<?> paramClass, String paramString, Class<?>[] paramArrayOfClass)
  {
    Assert.notNull(paramClass, "Class must not be null");
    Assert.notNull(paramString, "Method name must not be null");
    try
    {
      Method localMethod = paramClass.getMethod(paramString, paramArrayOfClass);
      return localMethod;
    }
    catch (NoSuchMethodException localNoSuchMethodException)
    {
    }
    return null;
  }

  public static Method getMostSpecificMethod(Method paramMethod, Class<?> paramClass)
  {
    Method localMethod = null;
    if (paramMethod != null)
    {
      boolean bool1 = isOverridable(paramMethod, paramClass);
      localMethod = null;
      if (bool1)
      {
        localMethod = null;
        if (paramClass != null)
        {
          boolean bool2 = paramClass.equals(paramMethod.getDeclaringClass());
          localMethod = null;
          if (!bool2)
            localMethod = ReflectionUtils.findMethod(paramClass, paramMethod.getName(), paramMethod.getParameterTypes());
        }
      }
    }
    if (localMethod != null)
      return localMethod;
    return paramMethod;
  }

  public static String getPackageName(Class<?> paramClass)
  {
    Assert.notNull(paramClass, "Class must not be null");
    String str = paramClass.getName();
    int i = str.lastIndexOf('.');
    if (i != -1)
      return str.substring(0, i);
    return "";
  }

  public static String getQualifiedMethodName(Method paramMethod)
  {
    Assert.notNull(paramMethod, "Method must not be null");
    return paramMethod.getDeclaringClass().getName() + "." + paramMethod.getName();
  }

  public static String getQualifiedName(Class<?> paramClass)
  {
    Assert.notNull(paramClass, "Class must not be null");
    if (paramClass.isArray())
      return getQualifiedNameForArray(paramClass);
    return paramClass.getName();
  }

  private static String getQualifiedNameForArray(Class<?> paramClass)
  {
    StringBuilder localStringBuilder = new StringBuilder();
    while (true)
    {
      if (!paramClass.isArray())
      {
        localStringBuilder.insert(0, paramClass.getName());
        return localStringBuilder.toString();
      }
      paramClass = paramClass.getComponentType();
      localStringBuilder.append("[]");
    }
  }

  public static String getShortName(Class<?> paramClass)
  {
    return getShortName(getQualifiedName(paramClass));
  }

  public static String getShortName(String paramString)
  {
    Assert.hasLength(paramString, "Class name must not be empty");
    int i = paramString.lastIndexOf('.');
    int j = paramString.indexOf("$$");
    if (j == -1)
      j = paramString.length();
    return paramString.substring(i + 1, j).replace('$', '.');
  }

  public static String getShortNameAsProperty(Class<?> paramClass)
  {
    String str = getShortName(paramClass);
    int i = str.lastIndexOf('.');
    if (i != -1)
      str = str.substring(i + 1);
    return Introspector.decapitalize(str);
  }

  public static Method getStaticMethod(Class<?> paramClass, String paramString, Class<?>[] paramArrayOfClass)
  {
    Assert.notNull(paramClass, "Class must not be null");
    Assert.notNull(paramString, "Method name must not be null");
    try
    {
      Method localMethod = paramClass.getMethod(paramString, paramArrayOfClass);
      boolean bool = Modifier.isStatic(localMethod.getModifiers());
      if (bool)
        return localMethod;
      return null;
    }
    catch (NoSuchMethodException localNoSuchMethodException)
    {
    }
    return null;
  }

  public static Class<?> getUserClass(Class<?> paramClass)
  {
    if ((paramClass != null) && (paramClass.getName().contains("$$")))
    {
      Class localClass = paramClass.getSuperclass();
      if ((localClass != null) && (!Object.class.equals(localClass)))
        return localClass;
    }
    return paramClass;
  }

  public static Class<?> getUserClass(Object paramObject)
  {
    Assert.notNull(paramObject, "Instance must not be null");
    return getUserClass(paramObject.getClass());
  }

  public static boolean hasAtLeastOneMethodWithName(Class<?> paramClass, String paramString)
  {
    Assert.notNull(paramClass, "Class must not be null");
    Assert.notNull(paramString, "Method name must not be null");
    Method[] arrayOfMethod = paramClass.getDeclaredMethods();
    int i = arrayOfMethod.length;
    int j = 0;
    Class[] arrayOfClass;
    int k;
    if (j >= i)
    {
      arrayOfClass = paramClass.getInterfaces();
      k = arrayOfClass.length;
    }
    for (int m = 0; ; m++)
    {
      if (m >= k)
        if ((paramClass.getSuperclass() == null) || (!hasAtLeastOneMethodWithName(paramClass.getSuperclass(), paramString)))
          break label110;
      while (hasAtLeastOneMethodWithName(arrayOfClass[m], paramString))
      {
        do
          return true;
        while (arrayOfMethod[j].getName().equals(paramString));
        j++;
        break;
      }
    }
    label110: return false;
  }

  public static boolean hasConstructor(Class<?> paramClass, Class<?>[] paramArrayOfClass)
  {
    return getConstructorIfAvailable(paramClass, paramArrayOfClass) != null;
  }

  public static boolean hasMethod(Class<?> paramClass, String paramString, Class<?>[] paramArrayOfClass)
  {
    return getMethodIfAvailable(paramClass, paramString, paramArrayOfClass) != null;
  }

  public static boolean isAssignable(Class<?> paramClass1, Class<?> paramClass2)
  {
    Assert.notNull(paramClass1, "Left-hand side type must not be null");
    Assert.notNull(paramClass2, "Right-hand side type must not be null");
    if (paramClass1.isAssignableFrom(paramClass2));
    Class localClass2;
    do
    {
      return true;
      if (!paramClass1.isPrimitive())
        break;
      localClass2 = (Class)primitiveWrapperTypeMap.get(paramClass2);
    }
    while ((localClass2 != null) && (paramClass1.equals(localClass2)));
    Class localClass1;
    do
    {
      return false;
      localClass1 = (Class)primitiveTypeToWrapperMap.get(paramClass2);
    }
    while ((localClass1 == null) || (!paramClass1.isAssignableFrom(localClass1)));
    return true;
  }

  public static boolean isAssignableValue(Class<?> paramClass, Object paramObject)
  {
    Assert.notNull(paramClass, "Type must not be null");
    if (paramObject != null)
      return isAssignable(paramClass, paramObject.getClass());
    return !paramClass.isPrimitive();
  }

  public static boolean isCacheSafe(Class<?> paramClass, ClassLoader paramClassLoader)
  {
    Assert.notNull(paramClass, "Class must not be null");
    ClassLoader localClassLoader1 = paramClass.getClassLoader();
    if (localClassLoader1 == null)
      return false;
    ClassLoader localClassLoader2 = paramClassLoader;
    if (localClassLoader2 == localClassLoader1)
      return true;
    while (localClassLoader2 != null)
    {
      localClassLoader2 = localClassLoader2.getParent();
      if (localClassLoader2 == localClassLoader1)
        return true;
    }
    return false;
  }

  private static boolean isOverridable(Method paramMethod, Class paramClass)
  {
    if (Modifier.isPrivate(paramMethod.getModifiers()))
      return false;
    if ((Modifier.isPublic(paramMethod.getModifiers())) || (Modifier.isProtected(paramMethod.getModifiers())))
      return true;
    return getPackageName(paramMethod.getDeclaringClass()).equals(getPackageName(paramClass));
  }

  @Deprecated
  public static boolean isPresent(String paramString)
  {
    return isPresent(paramString, getDefaultClassLoader());
  }

  public static boolean isPresent(String paramString, ClassLoader paramClassLoader)
  {
    try
    {
      forName(paramString, paramClassLoader);
      return true;
    }
    catch (Throwable localThrowable)
    {
    }
    return false;
  }

  public static boolean isPrimitiveArray(Class<?> paramClass)
  {
    Assert.notNull(paramClass, "Class must not be null");
    return (paramClass.isArray()) && (paramClass.getComponentType().isPrimitive());
  }

  public static boolean isPrimitiveOrWrapper(Class<?> paramClass)
  {
    Assert.notNull(paramClass, "Class must not be null");
    return (paramClass.isPrimitive()) || (isPrimitiveWrapper(paramClass));
  }

  public static boolean isPrimitiveWrapper(Class<?> paramClass)
  {
    Assert.notNull(paramClass, "Class must not be null");
    return primitiveWrapperTypeMap.containsKey(paramClass);
  }

  public static boolean isPrimitiveWrapperArray(Class<?> paramClass)
  {
    Assert.notNull(paramClass, "Class must not be null");
    return (paramClass.isArray()) && (isPrimitiveWrapper(paramClass.getComponentType()));
  }

  public static boolean isVisible(Class<?> paramClass, ClassLoader paramClassLoader)
  {
    if (paramClassLoader == null);
    while (true)
    {
      return true;
      try
      {
        Class localClass = paramClassLoader.loadClass(paramClass.getName());
        if (paramClass != localClass)
          return false;
      }
      catch (ClassNotFoundException localClassNotFoundException)
      {
      }
    }
    return false;
  }

  public static boolean matchesTypeName(Class<?> paramClass, String paramString)
  {
    return (paramString != null) && ((paramString.equals(paramClass.getName())) || (paramString.equals(paramClass.getSimpleName())) || ((paramClass.isArray()) && (paramString.equals(getQualifiedNameForArray(paramClass)))));
  }

  public static ClassLoader overrideThreadContextClassLoader(ClassLoader paramClassLoader)
  {
    Thread localThread = Thread.currentThread();
    ClassLoader localClassLoader = localThread.getContextClassLoader();
    if ((paramClassLoader != null) && (!paramClassLoader.equals(localClassLoader)))
    {
      localThread.setContextClassLoader(paramClassLoader);
      return localClassLoader;
    }
    return null;
  }

  private static void registerCommonClasses(Class<?>[] paramArrayOfClass)
  {
    int i = paramArrayOfClass.length;
    for (int j = 0; ; j++)
    {
      if (j >= i)
        return;
      Class<?> localClass = paramArrayOfClass[j];
      commonClassCache.put(localClass.getName(), localClass);
    }
  }

  public static Class<?> resolveClassName(String paramString, ClassLoader paramClassLoader)
    throws IllegalArgumentException
  {
    try
    {
      Class localClass = forName(paramString, paramClassLoader);
      return localClass;
    }
    catch (ClassNotFoundException localClassNotFoundException)
    {
      throw new IllegalArgumentException("Cannot find class [" + paramString + "]", localClassNotFoundException);
    }
    catch (LinkageError localLinkageError)
    {
      throw new IllegalArgumentException("Error loading class [" + paramString + "]: problem with class file or dependent class.", localLinkageError);
    }
  }

  public static Class<?> resolvePrimitiveClassName(String paramString)
  {
    Class localClass = null;
    if (paramString != null)
    {
      int i = paramString.length();
      localClass = null;
      if (i <= 8)
        localClass = (Class)primitiveTypeNameMap.get(paramString);
    }
    return localClass;
  }

  public static Class<?> resolvePrimitiveIfNecessary(Class<?> paramClass)
  {
    Assert.notNull(paramClass, "Class must not be null");
    if ((paramClass.isPrimitive()) && (paramClass != Void.TYPE))
      return (Class)primitiveTypeToWrapperMap.get(paramClass);
    return paramClass;
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     org.springframework.util.ClassUtils
 * JD-Core Version:    0.6.2
 */